package com.itcast.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itcast.admin.base.BaseController;
import com.itcast.admin.common.result.CmsResult;
import com.itcast.admin.constant.CommonReturnCode;
import com.itcast.admin.service.AdminService;

@Controller
public class AdminController extends BaseController{

	@Autowired
	private AdminService adminService;
	
	@RequestMapping(value = "/", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
	public String first() {
	
		return redirectTo("/login");
	}
	
	@RequestMapping(value = "/login", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
	public String getLoginPage() {
	
		return "/modules/login/login";
	}
	
	@RequestMapping(value = "/loginAction", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	@ResponseBody
	public Object login(@RequestParam("loginName") String loginName,
			@RequestParam("loginPassword") String loginPassword) {
		
		return new CmsResult(CommonReturnCode.SUCCESS, 1);
	}
	
	@RequestMapping(value = "/home", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
	public String getHomePage() {
		
		return "/modules/login/home";
	}
	
}
